package pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@AllArgsConstructor
@NoArgsConstructor
@Data
public class CartItem {
    private Product product;        // 所购买的某件商品
    private int num;                // 购买的某件商品的数量
    private double total;           // 某件商品的总金额

    public CartItem(Product product, int num) {
        this.product = product;
        this.num = num;
    }

    public void setTotal(double total) {
        this.total = this.num * product.getPrice();
    }

}
